package cs_15110100511.recyclerview_511_ydp.activity;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;

import cs_15110100511.recyclerview_511_ydp.R;
import cs_15110100511.recyclerview_511_ydp.bean.UserBean;
import cs_15110100511.recyclerview_511_ydp.iface.LoginListener;
import cs_15110100511.recyclerview_511_ydp.model.LoginModel;

public class LoginActivity extends AppCompatActivity implements LoginListener,View.OnClickListener {
    private EditText et_userName, et_password;
    private Button btn_login, btn_register;
    private CheckBox checkBox_remember;
    private Context context;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        context = LoginActivity.this;
        init();
    }

    private void init() {
        et_password = (EditText) findViewById(R.id.et_password);
        et_userName = (EditText) findViewById(R.id.et_username);
        btn_login = (Button) findViewById(R.id.btn_login);
        btn_register = (Button) findViewById(R.id.btn_register);
        btn_login.setOnClickListener(this);
        btn_register.setOnClickListener(this);
        checkBox_remember = (CheckBox) findViewById(R.id.checkbox_remember);

        }

        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.btn_login:
                String s_username = et_userName.getText().toString();
                String password = et_password.getText().toString();
                LoginModel mode = new LoginModel();
                mode.login(s_username, password, this);
                break;
            case R.id.btn_register:
                break;
        }
    }

    @Override
    public void onResponse(UserBean userBean) {

    }

    @Override
    public void onFail(String msg) {

    }
}